package com.hjy.elasticsearch.entity;

import com.hjy.elasticsearch.util.DateUtil;
import io.searchbox.annotations.JestId;

import java.io.Serializable;
import java.util.Date;

public class Entity implements Serializable {

    private static final long serialVersionUID = -763638353551774166L;

    public static final String INDEX_NAME = "index_entity";//对应的存入Elasticsearch的表名，必须是小写

    public static final String TYPE = "tstype";//分组名称

    @JestId//将该实体类的ID作为了存储到ES中的ID，如果不使用，ES会随机生成，就不能保证数据的唯一性，同事保存同一个ID的数据，还会更新掉老的数据
    private Long id;

    private String name;

    private Long time;

    private String surname;

    public Entity() {
        super();
    }

    public Entity(Long id, String name) {
        this.id = id;
        this.name = name;
    }
    public Entity(Long id, String name,String surname) {
        this.id = id;
        this.name = name;
        this.surname = surname;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    public Date getTime() {
        return DateUtil.getDateByLong(time);
    }


    public void setTime(Date Time) {
        if(Time != null){
            this.time = Time.getTime();
        }
    }
}
